#include<bits/stdc++.h>
using namespace std;
long long n,l,r,sum,yl;
int main()
{
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	
	cin>>n>>l>>r;
	sum=r-l;
	if(sum>=n-1)
		cout<<n-1;
	else{
		yl=l%n;
		if(yl+sum>=n)
			cout<<n-1;
		else
			cout<<yl+sum;
	}
	return 0;
}
